<template>
  <div class="statistics-container">
    <el-row :gutter="20">
      <el-col :span="12">
        <el-card class="chart-card">
          <template #header>
            <div class="card-header">
              <span>借阅趋势统计</span>
              <el-radio-group v-model="trendTimeRange" size="small">
                <el-radio-button label="week">周</el-radio-button>
                <el-radio-button label="month">月</el-radio-button>
                <el-radio-button label="year">年</el-radio-button>
              </el-radio-group>
            </div>
          </template>
          <div class="chart-container">
            <borrow-trend :time-range="trendTimeRange" />
          </div>
        </el-card>
      </el-col>
      
      <el-col :span="12">
        <el-card class="chart-card">
          <template #header>
            <div class="card-header">
              <span>图书分类统计</span>
            </div>
          </template>
          <div class="chart-container">
            <book-category />
          </div>
        </el-card>
      </el-col>
    </el-row>

    <el-row :gutter="20" class="mt-4">
      <el-col :span="24">
        <el-card>
          <template #header>
            <div class="card-header">
              <span>热门图书排行</span>
            </div>
          </template>
          <top-books />
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import BorrowTrend from '@/components/charts/BorrowTrend.vue';
import BookCategory from '@/components/charts/BookCategory.vue';
import TopBooks from '@/components/charts/TopBooks.vue';

const trendTimeRange = ref('month');
</script>

<style scoped>
.statistics-container {
  padding: 20px;
}
.chart-card {
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chart-container {
  height: 300px;
}
.mt-4 {
  margin-top: 20px;
}
.ranking-table-container {
  padding: 10px;
}

:deep(.el-table) {
  --el-table-header-text-color: #606266;
  --el-table-header-bg-color: #f5f7fa;
}

:deep(.el-table th) {
  font-weight: bold;
}

:deep(.el-table__cell) {
  padding: 8px 0;
}
</style>
